# _*_ coding:utf-8 _*_
import pygame
from pygame.locals import *
import sys

musicstr="D:/声音文件/不畏侠.mp3"
# musicstr="../sound/Minecraft-Levelup.wav"
pygame.mixer.pre_init(44100, 16, 2, 1024*4)
pygame.init()
pygame.mixer.music.load(musicstr)
pygame.mixer.music.play()
pygame.mixer.music.rewind()
pygame.mixer.music.set_volume(0.3)
dostr="unpause"
pos=0
screen=pygame.display.set_mode((600,500),0,32)
screen.fill(pygame.color.Color("gray"))
while True:
    event =pygame.event.poll()
    if event.type==QUIT:
        sys.exit()
    if event.type==KEYDOWN:
        if event.key==K_LEFT:
            pos=pygame.mixer.music.get_pos()
            pygame.mixer.music.set_pos(pos+500)
        if event.key==K_RIGHT:
            pos = pygame.mixer.music.get_pos()
            pygame.mixer.music.set_pos(pos - 500)
        if event.key==K_UP:
            # 重新播放pygame.mixer.music.rewind()
            pygame.mixer.music.play()
        if event.key==K_DOWN:
            pygame.mixer.music.stop()
        if event.key==K_SPACE:
            if dostr=="unpause":
                pygame.mixer.music.pause()
                dostr="pause"
            else:
                pygame.mixer.music.unpause()
                dostr="unpause"

    pygame.display.update()

pygame.quit()